tooltip: Add private api to allocate the window
authorMatthias Clasen <mclasen@redhat.com>
Wed, 6 May 2020 17:56:27 +0000 (13:56 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 6 May 2020 18:27:45 +0000 (14:27 -0400)
Add private gtk_tooltip_maybe_allocate() function
and use it from GtkWindow and GtkPopover.

This will let us stop using the ::size-allocate signal,
without having to redo all the tooltip management first.

That will happen later.

gtk/gtkpopover.c
gtk/gtktooltip.c
gtk/gtktooltipprivate.h
gtk/gtkwindow.c

index 6ffc7f7126412ef98cbec0110428fc1f95a705e5..7b21e2b725d23de450eac4eb81fdf973c05d437a 100644 (file)
 #include "gtksnapshot.h"
 #include "gtkshortcutmanager.h"
 #include "gtkbuildable.h"
+#include "gtktooltipprivate.h"
 
 #include "gtkrender.h"
 #include "gtkstylecontextprivate.h"
@@ -1417,6 +1418,8 @@ gtk_popover_size_allocate (GtkWidget *widget,
       gtk_popover_update_shape (popover);
       g_clear_pointer (&priv->arrow_render_node, gsk_render_node_unref);
     }
+
+  gtk_tooltip_maybe_allocate (GTK_NATIVE (popover));
 }
 
 static void
index f611b4f5620fd585357029113d0cea5d21ad2db4..fc9e665444bf348633bd1b2307dbe95b61bdcf7e 100644 (file)
@@ -977,3 +977,16 @@ gtk_tooltip_handle_event_internal (GdkEventType   event_type,
        break;
     }
 }
+
+void
+gtk_tooltip_maybe_allocate (GtkNative *native)
+{
+  GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (native));
+  GtkTooltip *tooltip;
+
+  tooltip = g_object_get_qdata (G_OBJECT (display), quark_current_tooltip);
+  if (!tooltip || GTK_NATIVE (tooltip->native) != native)
+    return;
+
+  gtk_native_check_resize (GTK_NATIVE (tooltip->window));
+}
index 5a050da1993f0c56b95eb94d3a2afa4418104544..ca63406b2c11a6743b6c7b705e6e1118ed4220ce 100644 (file)
@@ -27,6 +27,7 @@
 
 
 #include <gtk/gtktooltip.h>
+#include <gtk/gtknative.h>
 
 
 G_BEGIN_DECLS
@@ -42,6 +43,8 @@ GtkWidget * _gtk_widget_find_at_coords   (GdkSurface         *surface,
                                           gint               *widget_x,
                                           gint               *widget_y);
 
+void gtk_tooltip_maybe_allocate          (GtkNative          *native);
+
 G_END_DECLS
 
 
index 471fcc87388da10a9642b17d3582202934fad76b..bc79bd3d281b9d9052f1ed6844eba1f543e5e774 100644 (file)
@@ -70,6 +70,7 @@
 #include "gtkwindowgroup.h"
 #include "gtkpopovermenubarprivate.h"
 #include "gtkcssboxesimplprivate.h"
+#include "gtktooltipprivate.h"
 
 #include "a11y/gtkwindowaccessibleprivate.h"
 #include "a11y/gtkcontaineraccessibleprivate.h"
@@ -5076,6 +5077,8 @@ gtk_window_size_allocate (GtkWidget *widget,
 
   if (child && gtk_widget_get_visible (child))
     gtk_widget_size_allocate (child, &child_allocation, -1);
+
+  gtk_tooltip_maybe_allocate (GTK_NATIVE (widget));
 }
 
 gboolean